package com.huang.factory;

/**
 * <p></p>
 *
 * @author aneng huang
 * @since 2020-10-27 11:06:43
 */
public class CalculatorFactory {

    public static OperatorTwo createOperator(String operator) {
        OperatorTwo result;
        switch (operator) {
            case "+":
                result = new OperatorAdd();
                break;
            case "-":
                result = new OperatorSub();
                break;
            case "*":
                result = new OperatorMul();
                break;
            case "/":
                result = new OperatorDiv();
                break;
            default:
                throw new RuntimeException("操作不存在");
        }
        return result;
    }
}
